#ifndef AUTHSERVER_H
#define AUTHSERVER_H

#include "CoreSettings.h"

class CPlayer;
class CCoreDatabase;
class CISCServer;

/*
* Classe CAuthServer
* -> Authentifie les joueurs et leur envoie la liste des serveurs
*/
class CAuthServer
{
public:
	CAuthServer(CAuthSettings* settings, CCoreDatabase* database, CISCServer* isc);

	~CAuthServer();

	bool init(CNetwork *network);

	bool run();

private:
	CAuthSettings* m_settings;

	CNetAcceptor* m_acceptor;

	CCoreDatabase* m_database;

	CISCServer* m_isc;

	CArray<CPlayer*> m_players;

	CPlayer* _getPlayer(int id);

	CPlayer* _createPlayer(CNetClient *client);

	int _generatePlayerId();

	bool _handlePacket(CPlayer *player);

	void _cmdHandler_auth(CPlayer *player);

	void _cmdHandler_retry(CPlayer *player);
};

#endif // AUTHSERVER_H